﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AllProjectTest
{
    [TestClass]
    public class TestMethods
    {
        [TestMethod]
        public void TestNameMethod()
        {
            StringWriter strWriter = new StringWriter();
            Console.SetOut(strWriter);
            NameMethod.PrintName("Ivan");
            string expected = string.Format("Hello, Ivan\r\n");
            Assert.AreEqual(expected, string.Format(strWriter.ToString()));

        }

        [TestMethod]
        public void TestNumberCount()
        {
            int result = NumberCount.Count(new int[] { 2, 3, 9, 3, 3, 3 }, 3);
            Assert.AreEqual(4, result);
        }

        [TestMethod]
        public void TestCalculateFactorial()
        {
            string strNumber = "10888869450418352160768000000";
            BigInteger number = new BigInteger();
            number = BigInteger.Parse(strNumber);
            List<int> testList = new List<int>();
            while (number > 0)
            {
                BigInteger temp = number % 10;
                testList.Add((int)temp);
                number /= 10;
            }
            List<int> result = CalculateFactorial.MultiplyIntegers(27);
            for (int i = 0; i < testList.Count; i++)
            {
                Assert.AreEqual<int>(testList[i], result[i]);
            }
        }
    }
}
